package lib

import "math"

func init() {
	Probs = append(Probs, Problem{
		Num:         7,
		Discription: "整数反转",
		Level:       2,
		Labels: map[string]int{
			"大整数":  1,
			"位数操作": 1,
		},
	})
}

func Reverse(x int) int {
	res := 0
	for x != 0 {
		last := x % 10
		res = res*10 + last
		x /= 10
	}

	if res > math.MaxInt32 || res < math.MinInt32 {
		return 0
	}

	return res
}